#ifndef PLANWIDGET_H
#define PLANWIDGET_H

//#include "Wt/WContainerWidget"
#include "Wt/WTabWidget"

namespace Wt {
    class WPanel;
    class WStackedWidget;
    class WAnchor;
    class WText;
    class WTextEdit;
    class WTextArea;
    class WPushButton;
    class WTabWidget;
    class WGridLayout;
}

#include <QVector>
#include "DbSession.h"

using namespace Wt;




class PlanWidget : public /* WContainerWidget */ WTabWidget
{
public:
    enum PlanType {
        DIET,
        FITNESS
    };

private:
    PlanType planType;
    int userId;
    bool other;
    int guestId;
    WContainerWidget *planPanel;
    WStackedWidget *stackedWidget;
    WContainerWidget *showView;
    WPushButton *editButton;
    WText *planText;
    WContainerWidget *editView;
    WTextEdit *planEdit;
    WPushButton *saveEdit;
    WPushButton *cancelEdit;
    WContainerWidget *commentsWidget;
    WPushButton *prevPlan;
    WPushButton *nextPlan;
    WPushButton *newPlan;
    WText *planModified;

    QSharedPointer<QVector<QSharedPointer<DietPlan> > > dietPlans;
    QSharedPointer<QVector<QSharedPointer<FitnessPlan> > > fitnessPlans;

    QVector<WContainerWidget*> comments;
    int amountOfPlans;
    int currentPlan;

    /* for adding comments */
    WPushButton *addCommentButton;
    WTextEdit *addCommentEdit;
    WContainerWidget *addCommentWidget;

public:
    PlanWidget(int userId, PlanType planType, WObject *parent = 0, bool other = false, int guestId = 0);
    virtual ~PlanWidget();

    void setShowView();
    void setEditView();
    void update();

    /* slots */
    void onEditClicked();
    void onSaveClicked();
    void onCancelClicked();
    void onPrevClicked();
    void onNextClicked();
    void onNewClicked();
    void onAddCommentClicked();
};

#endif // PLANWIDGET_H
